<!doctype html><html lang=en dir=auto>
<head><meta charset=utf-8>
<meta http-equiv=x-ua-compatible content="IE=edge">
<meta name=viewport content="width=device-width,initial-scale=1,shrink-to-fit=no">
<meta name=robots content="index, follow">
<title>iOS开发杂货 | wenbin</title>
<meta name=keywords content>
<meta name=description content>
<meta name=author content>
<link rel=canonical href=https://imwenbin.com/tags/ios%E5%BC%80%E5%8F%91%E6%9D%82%E8%B4%A7/>
<link crossorigin=anonymous href=/assets/css/stylesheet.min.css rel="preload stylesheet" as=style>
<link rel=icon href=https://imwenbin.com/favicon.ico>
<link rel=icon type=image/png sizes=16x16 href=https://imwenbin.com/favicon16x16.png>
<link rel=icon type=image/png sizes=32x32 href=https://imwenbin.com/favicon32x32.png>
<link rel=apple-touch-icon href=https://imwenbin.com/apple_touch_icon.png>
<link rel=mask-icon href=https://imwenbin.com/safari_pinned_tab.svg>
<meta name=theme-color content="#2e2e33">
<meta name=msapplication-TileColor content="#2e2e33">
<meta name=generator content="Hugo 0.89.3">
<link rel=alternate type=application/rss+xml href=https://imwenbin.com/tags/ios%E5%BC%80%E5%8F%91%E6%9D%82%E8%B4%A7/index.xml>
<noscript>
<style>#theme-toggle,.top-link{display:none}</style>
<style>@media(prefers-color-scheme:dark){:root{--theme:rgb(29, 30, 32);--entry:rgb(46, 46, 51);--primary:rgb(218, 218, 219);--secondary:rgb(155, 156, 157);--tertiary:rgb(65, 66, 68);--content:rgb(196, 196, 197);--hljs-bg:rgb(46, 46, 51);--code-bg:rgb(55, 56, 62);--border:rgb(51, 51, 51)}.list{background:var(--theme)}.list:not(.dark)::-webkit-scrollbar-track{background:0 0}.list:not(.dark)::-webkit-scrollbar-thumb{border-color:var(--theme)}}</style>
</noscript><meta property="og:title" content="iOS开发杂货">
<meta property="og:description" content>
<meta property="og:type" content="website">
<meta property="og:url" content="https://imwenbin.com/tags/ios%E5%BC%80%E5%8F%91%E6%9D%82%E8%B4%A7/"><meta property="og:site_name" content="wenbin">
<meta name=twitter:card content="summary">
<meta name=twitter:title content="iOS开发杂货">
<meta name=twitter:description content>
</head>
<body class=list id=top>
<script>localStorage.getItem("pref-theme")==="dark"?document.body.classList.add('dark'):localStorage.getItem("pref-theme")==="light"?document.body.classList.remove('dark'):window.matchMedia('(prefers-color-scheme: dark)').matches&&document.body.classList.add('dark')</script>
<header class=header>
<nav class=nav>
<div class=logo>
<a href=https://imwenbin.com/ accesskey=h title="wenbin (Alt + H)">wenbin</a>
<span class=logo-switches>
<button id=theme-toggle accesskey=t title="(Alt + T)"><svg id="moon" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z"/></svg><svg id="sun" xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="5"/><line x1="12" y1="1" x2="12" y2="3"/><line x1="12" y1="21" x2="12" y2="23"/><line x1="4.22" y1="4.22" x2="5.64" y2="5.64"/><line x1="18.36" y1="18.36" x2="19.78" y2="19.78"/><line x1="1" y1="12" x2="3" y2="12"/><line x1="21" y1="12" x2="23" y2="12"/><line x1="4.22" y1="19.78" x2="5.64" y2="18.36"/><line x1="18.36" y1="5.64" x2="19.78" y2="4.22"/></svg>
</button>
</span>
</div>
<ul id=menu>
<li>
<a href=https://imwenbin.com/blog/ title=Blog>
<span>Blog</span>
</a>
</li>
<li>
<a href=https://imwenbin.com/archives title=Archive>
<span>Archive</span>
</a>
</li>
<li>
<a href=https://imwenbin.com/tags title=Tags>
<span>Tags</span>
</a>
</li>
</ul>
</nav>
</header>
<main class=main>
<header class=page-header><div class=breadcrumbs><a href=https://imwenbin.com/>Home</a>&nbsp;»&nbsp;<a href=https://imwenbin.com/tags/>Tags</a></div>
<h1>iOS开发杂货</h1>
</header>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>Vim 基础操作（一）
</h2>
</header>
<section class=entry-content>
<p>命令默认都在 Mac 自带终端使用
基础操作 使用 Vim 打开一个文件 cd 文件路径 vim 文件名 进入普通模式 输入模式 在普通模式下按 i 进入输入模式
退出 在输入模式下按 Esc 进入普通模式，接着可以输入命令： :q 直接退出 :q! 退出并丢弃修改 :x 保存并退出
光标移动 方向键 h l j k 四个键 h : 向左移动一个字符 l ：向右移动一个字符 j ：向下移动一行 k：向上移动一行 重复移动 在四个键前加个数字，例如：
10h：向左移动10个字符 7k：向上移动7个字符 单词移动 Option 键 w b e ge w：移动到下一个单词首 b：移动到上一个单词首 e：移动到下一个单词尾 ge：移动到上一个单词尾 行移动 在普通模式下移动...</p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:45:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to Vim 基础操作（一）" href=https://imwenbin.com/blog/vim-%E5%9F%BA%E7%A1%80%E6%93%8D%E4%BD%9C%E4%B8%80/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>Swift5 访问限制关键字
</h2>
</header>
<section class=entry-content>
<p>访问控制关键字 限制从高到低排列
private fileprivate internal public open 简单总结： private 只能在当前文件的当前模块的作用域使用 fileprivate 只能在当前文件内使用 internal 是默认访问级别，所有没有单独列出的都是这个权限 public 可以在外部文件访问，如果只需要访问就用它 open 可以在外部文件访问，如果需要继承和重写就用它
更多详细区别： https://swiftgg.gitbook.io/swift/swift-jiao-cheng/25_access_control</p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:43:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to Swift5 访问限制关键字" href=https://imwenbin.com/blog/swift5-%E8%AE%BF%E9%97%AE%E9%99%90%E5%88%B6%E5%85%B3%E9%94%AE%E5%AD%97/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>CocoaPods版本升级
</h2>
</header>
<section class=entry-content>
<p> 查看当前 Cocoapods版本 pod --version
检查当前 ruby 源，使用 gems.ruby-china.com 源 gem source -l gem sources --remove 旧源 gem sources -a 新源
更新Cocoapods sudo gem install cocoapods 回车然后输入电脑密码
再次检查当前Cocoapods版本 pod --version
完成
</p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:42:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to CocoaPods版本升级" href=https://imwenbin.com/blog/cocoapods%E7%89%88%E6%9C%AC%E5%8D%87%E7%BA%A7/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>多人开发git提交流程
</h2>
</header>
<section class=entry-content>
<p> 本文以master和dev举例，可视化git工具为sourceTree
在 dev 开发完成后提交到本地，不推送到远程 切换到 master 拉去远程分支代码 show in finder 打开项目运行，没有问题后切换到 dev 分支 将 master 分支合并到 dev ，运行代码 没有冲突：运行step5
有冲突
两人操作同一份类文件冲突： 定位到冲突文件，调整类文件代码顺序，清除冲突标记 在 sourceTree 中右键选择冲突文件，选择 解决冲突 提交后确认代码确认没有问题 工程文件冲突： 直接在 sourceTree 中选择冲突文件，选择 采用他人版本 show in finder 找回因采用他人版本自己本地被移除的本地文件 提价后运行代码，确保自己后面修改的文件都在，运行没有问题 解决完冲突提交后，跳回 master 分支，合并 dev 到 master 再次在 master 分支中运行项目，确保没有问题 提交并推送到远程 master 分支 跳转到 dev 分支继续开发 </p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:41:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to 多人开发git提交流程" href=https://imwenbin.com/blog/%E5%A4%9A%E4%BA%BA%E5%BC%80%E5%8F%91git%E6%8F%90%E4%BA%A4%E6%B5%81%E7%A8%8B/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>iOS 推送报错BadCertificateEnvironment
</h2>
</header>
<section class=entry-content>
<p>报 BadCertificateEnvironment 错一般来说是环境和证书不匹配，但是如果环境和证书确认没问题还报错，解决如下：
进钥匙串导出开发环境和发布环境的p12证书
❗️❗️❗️❗️❗️ 开发环境从私钥导出，发布环境从外层导出（千万别从私钥导出，否则会一直报这个错）
如图</p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:40:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to iOS 推送报错BadCertificateEnvironment" href=https://imwenbin.com/blog/ios-%E6%8E%A8%E9%80%81%E6%8A%A5%E9%94%99badcertificateenvironment/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>判断机型，支持最新设备（iPhone SE Gen2 和 iPad Pro 11 Gen2、iPad Pro 12.9 Gen4）
</h2>
</header>
<section class=entry-content>
<p>2020-7-10 更新 ⚠️已停止维护
现已支持CocoaPods
只涉及最新的iPhone和iPad设备
Github
// 导入这个框架 #import &lt;sys/utsname.h> + (NSString *)getDeviceName { struct utsname systemInfo; uname(&systemInfo); NSString *deviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding]; #pragma mark iPhone if ([deviceModel isEqualToString:@"iPhone1,1"]) return @"iPhone 1G"; if ([deviceModel isEqualToString:@"iPhone1,2"] || [deviceModel isEqualToString:@"iPhone1,2*"]) return @"iPhone 3G"; if ([deviceModel isEqualToString:@"iPhone2,1"] || [deviceModel isEqualToString:@"iPhone2,1*"]) return @"iPhone 3GS"; if ([deviceModel isEqualToString:@"iPhone3,1"] || [deviceModel isEqualToString:@"iPhone3,2"] || [deviceModel isEqualToString:@"iPhone3,3"]) return @"iPhone 4"; if ([deviceModel isEqualToString:@"iPhone4,1"] || [deviceModel isEqualToString:@"iPhone4,1*"]) return @"iPhone 4S"; if ([deviceModel isEqualToString:@"iPhone5,1"] || [deviceModel isEqualToString:@"iPhone5,2"]) return @"iPhone 5"; if ([deviceModel isEqualToString:@"iPhone5,3"] || [deviceModel isEqualToString:@"iPhone5,4"]) return @"iPhone 5C"; if ([deviceModel isEqualToString:@"iPhone6,1"] || [deviceModel isEqualToString:@"iPhone6,2"]) return @"iPhone 5S"; if ([deviceModel isEqualToString:@"iPhone7,2"]) return @"iPhone 6"; if ([deviceModel isEqualToString:@"iPhone7,1"]) return @"iPhone 6 Plus"; if ([deviceModel isEqualToString:@"iPhone8,1"]) return @"iPhone 6s"; if ([deviceModel isEqualToString:@"iPhone8,2"]) return @"iPhone 6s Plus"; if ([deviceModel isEqualToString:@"iPhone8,4"]) return @"iPhone SE"; if ([deviceModel isEqualToString:@"iPhone9,1"] || [deviceModel isEqualToString:@"iPhone9,3"]) return @"iPhone 7"; if ([deviceModel isEqualToString:@"iPhone9,2"] || [deviceModel isEqualToString:@"iPhone9,4"]) return @"iPhone 7 Plus"; if ([deviceModel isEqualToString:@"iPhone10,1"] || [deviceModel isEqualToString:@"iPhone10,4"]) return @"iPhone 8"; if ([deviceModel isEqualToString:@"iPhone10,2"] || [deviceModel isEqualToString:@"iPhone10,5"]) return @"iPhone 8 Plus"; if ([deviceModel isEqualToString:@"iPhone10,3"] || [deviceModel isEqualToString:@"iPhone10,6"]) return @"iPhone X"; if ([deviceModel isEqualToString:@"iPhone11,2"]) return @"iPhone XS"; if ([deviceModel isEqualToString:@"iPhone11,6"]) return @"iPhone XS Max"; if ([deviceModel isEqualToString:@"iPhone11,8"]) return @"iPhone XR"; if ([deviceModel isEqualToString:@"iPhone12,1"]) return @"iPhone 11"; if ([deviceModel isEqualToString:@"iPhone12,3"]) return @"iPhone 11 Pro"; if ([deviceModel isEqualToString:@"iPhone12,5"]) return @"iPhone 11 Pro Max"; if ([deviceModel isEqualToString:@"iPhone12,8"]) return @"iPhone SE Gen2"; #pragma mark iPad if ([deviceModel isEqualToString:@"iPad1,1"]) return @"iPad 1"; if ([deviceModel isEqualToString:@"iPad2,1"] || [deviceModel isEqualToString:@"iPad2,2"] || [deviceModel isEqualToString:@"iPad2,3"] || [deviceModel isEqualToString:@"iPad2,4"]) return @"iPad 2"; if ([deviceModel isEqualToString:@"iPad3,1"] || [deviceModel isEqualToString:@"iPad3,2"] || [deviceModel isEqualToString:@"iPad3,3"]) return @"iPad 3"; if ([deviceModel isEqualToString:@"iPad3,4"] || [deviceModel isEqualToString:@"iPad3,5"] || [deviceModel isEqualToString:@"iPad3,6"]) return @"iPad 4"; if ([deviceModel isEqualToString:@"iPad2,5"] || [deviceModel isEqualToString:@"iPad2,6"] || [deviceModel isEqualToString:@"iPad2,7"]) return @"iPad mini"; if ([deviceModel isEqualToString:@"iPad4,1"] || [deviceModel isEqualToString:@"iPad4,2"] || [deviceModel isEqualToString:@"iPad4,3"]) return @"iPad Air"; if ([deviceModel isEqualToString:@"iPad4,4"] || [deviceModel isEqualToString:@"iPad4,5"] || [deviceModel isEqualToString:@"iPad4,6"]) return @"iPad mini 2"; if ([deviceModel isEqualToString:@"iPad5,3"] || [deviceModel isEqualToString:@"iPad5,4"]) return @"iPad Air 2"; if ([deviceModel isEqualToString:@"iPad4,7"] || [deviceModel isEqualToString:@"iPad4,8"] || [deviceModel isEqualToString:@"iPad4,9"]) return @"iPad mini 3"; if ([deviceModel isEqualToString:@"iPad5,1"] || [deviceModel isEqualToString:@"iPad5,2"]) return @"iPad mini 4"; if ([deviceModel isEqualToString:@"iPad6,7"] || [deviceModel isEqualToString:@"iPad6,8"]) return @"iPad PRO 12....</p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:39:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to 判断机型，支持最新设备（iPhone SE Gen2 和 iPad Pro 11 Gen2、iPad Pro 12.9 Gen4）" href=https://imwenbin.com/blog/%E5%88%A4%E6%96%AD%E6%9C%BA%E5%9E%8B%E6%94%AF%E6%8C%81%E6%9C%80%E6%96%B0%E8%AE%BE%E5%A4%87iphone-se-gen2-%E5%92%8C-ipad-pro-11-gen2ipad-pro-12.9-gen4/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>Xcode打包每次输入用户名和密码
</h2>
</header>
<section class=entry-content>
<p>步骤 钥匙串 - 对应的证书秘钥 双击 - 访问控制 - 选择第一个 - 输入密码 完成 </p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:38:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to Xcode打包每次输入用户名和密码" href=https://imwenbin.com/blog/xcode%E6%89%93%E5%8C%85%E6%AF%8F%E6%AC%A1%E8%BE%93%E5%85%A5%E7%94%A8%E6%88%B7%E5%90%8D%E5%92%8C%E5%AF%86%E7%A0%81/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>Xcode警告☞The iOS deployment target is set to 7.0, but the range of supported deployment target versio
</h2>
</header>
<section class=entry-content>
<p>拿AFNetworking举例：
如果出现 The iOS deployment target is set to 7.0, but the range of supported deployment target versions for this platform is 8.0 to 12.1. (in target 'AFNetworking')
选中 Pods Project 在 target 中选警告提示的库 在 Build Settings 中搜索 iOS Deployment Target 并选择合适的版本 </p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:37:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to Xcode警告☞The iOS deployment target is set to 7.0, but the range of supported deployment target versio" href=https://imwenbin.com/blog/xcode%E8%AD%A6%E5%91%8Athe-ios-deployment-target-is-set-to-7.0-but-the-range-of-supported-deployment-target-versio/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>Xcode单元测试报错 Failed to load test bundle from file
</h2>
</header>
<section class=entry-content>
<p>在 test 的 target 选择 build Settings => iOS Deployment Target => 选择对应的版本 </p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:35:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to Xcode单元测试报错 Failed to load test bundle from file" href=https://imwenbin.com/blog/xcode%E5%8D%95%E5%85%83%E6%B5%8B%E8%AF%95%E6%8A%A5%E9%94%99-failed-to-load-test-bundle-from-file/></a>
</article>
<article class="post-entry tag-entry">
<header class=entry-header>
<h2>CocoaPods 私有库验证 --- 参数
</h2>
</header>
<section class=entry-content>
<p>pod lib lint 对spec文件做本地校验
pod spec lint 对spec文件做远程校验
--verbose 显示详细信息
--use-libraries 如果依赖了静态库使用这个可以校验通过
--allow-warnings 忽略警告
--sources 如果是私有库包含私有库的情况，在验证时加上这个属性：
--sources=https://xxxxx.git,https://github.com/CocoaPods/Specs.git 一个是从自己的私有仓库检索，一个是从Cocoapods的repo检索，按需添加，有多少个添加多少</p>
</section>
<footer class=entry-footer><span title="2021-11-18 09:34:36 +0800 CST">⌚️ 2021-11-18</span></footer>
<a class=entry-link aria-label="post link to CocoaPods 私有库验证 --- 参数" href=https://imwenbin.com/blog/cocoapods-%E7%A7%81%E6%9C%89%E5%BA%93%E9%AA%8C%E8%AF%81-%E5%8F%82%E6%95%B0/></a>
</article>
<footer class=page-footer>
<nav class=pagination>
<a class=prev href=https://imwenbin.com/tags/ios%E5%BC%80%E5%8F%91%E6%9D%82%E8%B4%A7/page/3/>« Prev Page</a>
<a class=next href=https://imwenbin.com/tags/ios%E5%BC%80%E5%8F%91%E6%9D%82%E8%B4%A7/page/5/>Next Page »</a>
</nav>
</footer>
</main>
<footer class=footer>
<span>&copy; 2021 <a href=https://imwenbin.com/>wenbin</a>.</span>
<span>
保留部分权利。
</span>
</footer>
<a href=#top aria-label="go to top" title="Go to Top (Alt + G)" class=top-link id=top-link accesskey=g><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 12 6" fill="currentcolor"><path d="M12 6H0l6-6z"/></svg>
</a>
<script>let menu=document.getElementById('menu');menu&&(menu.scrollLeft=localStorage.getItem("menu-scroll-position"),menu.onscroll=function(){localStorage.setItem("menu-scroll-position",menu.scrollLeft)}),document.querySelectorAll('a[href^="#"]').forEach(a=>{a.addEventListener("click",function(b){b.preventDefault();var a=this.getAttribute("href").substr(1);window.matchMedia('(prefers-reduced-motion: reduce)').matches?document.querySelector(`[id='${decodeURIComponent(a)}']`).scrollIntoView():document.querySelector(`[id='${decodeURIComponent(a)}']`).scrollIntoView({behavior:"smooth"}),a==="top"?history.replaceState(null,null," "):history.pushState(null,null,`#${a}`)})})</script>
<script>var mybutton=document.getElementById("top-link");window.onscroll=function(){document.body.scrollTop>800||document.documentElement.scrollTop>800?(mybutton.style.visibility="visible",mybutton.style.opacity="1"):(mybutton.style.visibility="hidden",mybutton.style.opacity="0")}</script>
<script>document.getElementById("theme-toggle").addEventListener("click",()=>{document.body.className.includes("dark")?(document.body.classList.remove('dark'),localStorage.setItem("pref-theme",'light')):(document.body.classList.add('dark'),localStorage.setItem("pref-theme",'dark'))})</script>
</body>
</html>